class HtmlOutputer(object):
    def __init__(self):
        self.datas = []

    def collectData(self, newData):
        if newData is None:
            return
        self.datas.append(newData)

    def outPutHtml(self):
        htmlFile = open("output.html", "w")
        htmlFile.write("<html>")
        htmlFile.write("<body>")
        htmlFile.write("<table>")
        htmlFile.write("<tr>")
        htmlFile.write("<td>网址</td>")
        htmlFile.write("<td>书名</td>")
        htmlFile.write("<td>作者</td>")
        htmlFile.write("<td>出版社</td>")
        htmlFile.write("<td>阅读人数</td>")
        htmlFile.write("<td>封面</td>")
        htmlFile.write("<td>简介</td>")
        htmlFile.write("<td>评论</td>")
        htmlFile.write("</tr>")
        for data in self.datas:
            htmlFile.write("<tr>")
            htmlFile.write("<td>%s</td>"%data['url'])
            htmlFile.write("<td>%s</td>" % data['bookName'])
            htmlFile.write("<td>%s</td>" % data['authorName'])
            htmlFile.write("<td>%s</td>" % data['publisher'])
            htmlFile.write("<td>%s</td>" % data['pop_height'])
            htmlFile.write("<td><img height=\"110px\" src=\"%s\"></td>" % data['book_img'])
            htmlFile.write("<td>%s</td>" % data['info_text'])
            htmlFile.write("<td>%s</td>" % data['comment'])
            htmlFile.write("</tr>")
        htmlFile.write("</table>")
        htmlFile.write("</body>")
        htmlFile.write("</html>")



